package com.utils;

public class Toolutils {
    private int pagecount;// 每页显示的条数
    private int sumcount;// 总条数
    private int currentpage;// 当前页

    private int prepage;//上一页
    private int sumpage;//总页数
    private int index;//索引
    private int nextpage;//下一页

    public static void main(String[] args) {
        Toolutils toolutils = new Toolutils(5, 34, 2);
        System.out.println("toolutils = " + toolutils);
    }

    public Toolutils(int pagecount, int sumcount, int currentpage) {
        this.pagecount = pagecount;
        this.sumcount = sumcount;
        this.currentpage = currentpage;

        prepage=currentpage==1?currentpage:currentpage-1;
        sumpage=sumcount/pagecount+(sumcount%pagecount==0?0:1);
        index=(currentpage-1)*pagecount;
        nextpage=(currentpage==sumpage?currentpage:currentpage+1);

//        prepage=currentpage==1?currentpage:currentpage-1;
//        sumpage= sumcount/pagecount+(sumcount%pagecount==0?0:1);
//        //索引从几开始
//        index=(currentpage-1)*pagecount;
//        nextpage=(currentpage==sumpage?currentpage:currentpage+1);
    }

    public int getPagecount() {
        return pagecount;
    }

    public void setPagecount(int pagecount) {
        this.pagecount = pagecount;
    }

    public int getSumcount() {
        return sumcount;
    }

    public void setSumcount(int sumcount) {
        this.sumcount = sumcount;
    }

    public int getCurrentpage() {
        return currentpage;
    }

    public void setCurrentpage(int currentpage) {
        this.currentpage = currentpage;
    }

    public int getPrepage() {
        return prepage;
    }

    public void setPrepage(int prepage) {
        this.prepage = prepage;
    }

    public int getSumpage() {
        return sumpage;
    }

    public void setSumpage(int sumpage) {
        this.sumpage = sumpage;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public int getNextpage() {
        return nextpage;
    }

    public void setNextpage(int nextpage) {
        this.nextpage = nextpage;
    }

    @Override
    public String toString() {
        return "Toolutils{" +
                "pagecount=" + pagecount +
                ", sumcount=" + sumcount +
                ", currentpage=" + currentpage +
                ", prepage=" + prepage +
                ", sumpage=" + sumpage +
                ", index=" + index +
                ", nextpage=" + nextpage +
                '}';
    }
}
